import javax.swing.ImageIcon;
import javax.swing.JLabel;

public class Token {
	private int xLocation;
	private int yLocation;
	private int tokenLocation = 0;
	private String tokenName;
	private boolean isAvailable=true;
	private boolean isGoToJail=false;
	private JLabel tokenLabel;
	private int startingpoint;
	private ImageIcon tokenIcon1, tokenIcon2, tokenIcon3, tokenIcon4;
	
	public Token(String name, int startingpoint){
		this.startingpoint = startingpoint;
		this.tokenName = name;
		this.isAvailable = false;
		if(startingpoint == 1){
			setTokenIcon(new ImageIcon("images/tokens/down-naruto.gif"));
			setTokenIcon2(new ImageIcon("images/tokens/left-naruto.gif"));
			setTokenIcon3(new ImageIcon("images/tokens/up-naruto.gif"));
			setTokenIcon4(new ImageIcon("images/tokens/right-naruto.gif"));
		}
		else if(startingpoint == 2){
			setTokenIcon(new ImageIcon("images/tokens/down-sasuke.gif"));
			setTokenIcon2(new ImageIcon("images/tokens/left-sasuke.gif"));
			setTokenIcon3(new ImageIcon("images/tokens/up-sasuke.gif"));
			setTokenIcon4(new ImageIcon("images/tokens/right-sasuke.gif"));
		}
		else if(startingpoint == 3){
			setTokenIcon(new ImageIcon("images/tokens/down-sakura.gif"));
			setTokenIcon2(new ImageIcon("images/tokens/left-sakura.gif"));
			setTokenIcon3(new ImageIcon("images/tokens/up-sakura.gif"));
			setTokenIcon4(new ImageIcon("images/tokens/right-sakura.gif"));
		}
		else if(startingpoint == 4){
			setTokenIcon(new ImageIcon("images/tokens/down-ochimaru.gif"));
			setTokenIcon2(new ImageIcon("images/tokens/left-ochimaru.gif"));
			setTokenIcon3(new ImageIcon("images/tokens/up-oshimaru.gif"));
			setTokenIcon4(new ImageIcon("images/tokens/right-ochimaru.gif"));
		}
		else if(startingpoint == 5){
			setTokenIcon(new ImageIcon("images/tokens/down-hinata.gif"));
			setTokenIcon2(new ImageIcon("images/tokens/left-hinata.gif"));
			setTokenIcon3(new ImageIcon("images/tokens/up-hinata.gif"));
			setTokenIcon4(new ImageIcon("images/tokens/right-hinata.gif"));
		}
		else if(startingpoint == 6){
			setTokenIcon(new ImageIcon("images/tokens/down-kakashi.gif"));
			setTokenIcon2(new ImageIcon("images/tokens/left-kakashi.gif"));
			setTokenIcon3(new ImageIcon("images/tokens/up-kakashi.gif"));
			setTokenIcon4(new ImageIcon("images/tokens/right-kakashi.gif"));
		}
		else if(startingpoint == 7){
			setTokenIcon(new ImageIcon("images/tokens/down-neji.gif"));
			setTokenIcon2(new ImageIcon("images/tokens/left-neji.gif"));
			setTokenIcon3(new ImageIcon("images/tokens/up-neji.gif"));
			setTokenIcon4(new ImageIcon("images/tokens/right-neji.gif"));
		}
		else if(startingpoint == 8){
			setTokenIcon(new ImageIcon("images/tokens/down-itachi.gif"));
			setTokenIcon2(new ImageIcon("images/tokens/left-itachi.gif"));
			setTokenIcon3(new ImageIcon("images/tokens/up-itachi.gif"));
			setTokenIcon4(new ImageIcon("images/tokens/right-itachi.gif"));
		}
		if(startingpoint == 1){
			xLocation = 605;
			yLocation = 625;
		}else if(startingpoint == 2){
			xLocation = 635;
			yLocation = 625;
		}else if(startingpoint == 3){
			xLocation = 605;
			yLocation = 647;
		}else if(startingpoint == 4){
			xLocation = 635;
			yLocation = 647;
		}else if(startingpoint == 5){
			xLocation = 605;
			yLocation = 669;
		}else if(startingpoint == 6){
			xLocation = 635;
			yLocation = 669;
		}else if(startingpoint == 7){
			xLocation = 620;
			yLocation = 636;
		}else if(startingpoint == 8){
			xLocation = 620;
			yLocation = 658;
		}
	}
	
	public void moveToken(){
		if(startingpoint == 1){
			if(yLocation == 625 && xLocation > 147){     
				tokenLabel.setIcon(tokenIcon2);
				this.xLocation = this.xLocation - 57;   
			 }else if(yLocation == 625 && xLocation > 90){
				this.xLocation = 45;   
				this.yLocation = 605;      
	         }else if(xLocation == 45 && yLocation > 147){     
					tokenLabel.setIcon(tokenIcon3);
				this.yLocation = this.yLocation -57 ;  
			 }else if(xLocation == 45 && yLocation > 90){ 
				this.yLocation = 45;     
			    this.xLocation = 65;    
			 }else if(yLocation == 45 && xLocation < 522){    
					tokenLabel.setIcon(tokenIcon4);
				this.xLocation = this.xLocation + 57;  
			 }else if(yLocation == 45 && xLocation < 579){ 
				this.xLocation =625;   
				this.yLocation = 65;  
		     }else if(xLocation == 625 && yLocation < 522){    
					tokenLabel.setIcon(tokenIcon1);
		        this.yLocation = this.yLocation + 57;     
			 }else if(xLocation == 625 && yLocation < 579){
				this.yLocation =625;     
				this.xLocation =605 ;    
			 }
			}else if(startingpoint == 2){
				if(yLocation == 625 && xLocation > 122){  
					tokenLabel.setIcon(tokenIcon2);
				this.xLocation = this.xLocation - 57;     
			 }else if(yLocation == 625 && xLocation > 45){
				this.xLocation = this.xLocation - 77;     
				this.yLocation = this.yLocation + 10;     
		     }else if(xLocation == 45 && yLocation > 122){  
					tokenLabel.setIcon(tokenIcon3);
				this.yLocation = this.yLocation -57 ;     
			 }else if(xLocation == 45 && yLocation > 45){ 
				this.yLocation = this.yLocation - 77;     
			    this.xLocation = this.xLocation - 10;     
			 }else if(yLocation == 45 && xLocation < 548){  
					tokenLabel.setIcon(tokenIcon4);
				this.xLocation = this.xLocation + 57;     
			 }else if(yLocation == 45 && xLocation < 625){
				this.xLocation = this.xLocation + 77;     
				this.yLocation = this.yLocation - 10;     
		     }else if(xLocation == 625 && yLocation < 548){  
					tokenLabel.setIcon(tokenIcon1);
		    	this.yLocation = this.yLocation + 57;     
			 }else if(xLocation == 625 && yLocation < 625){
				this.yLocation = this.yLocation + 77;     
				this.xLocation = this.xLocation + 10 ;    
			 }
		
			
			}else if(startingpoint == 3){
				if(yLocation == 647 && xLocation > 92){  
					tokenLabel.setIcon(tokenIcon2);
				this.xLocation = this.xLocation - 57;
			 }else if(yLocation == 647 && xLocation > 57){
				this.xLocation = 23;
				this.yLocation = 605;
	
		              }else if(xLocation == 23 && yLocation > 92){  
							tokenLabel.setIcon(tokenIcon3);
				this.yLocation = this.yLocation -57 ;
			 }else if(xLocation == 23 && yLocation > 57){
				this.yLocation = 23;
			              this.xLocation = 65;
	
			 }else if(yLocation == 23 && xLocation < 578){  
					tokenLabel.setIcon(tokenIcon4);
				this.xLocation = this.xLocation + 57;
			 }else if(yLocation == 23 && xLocation < 635){
				this.xLocation = 647;
				this.yLocation = 65;
	
		     }else if(xLocation == 647 && yLocation < 578){  
					tokenLabel.setIcon(tokenIcon1);
		        this.yLocation = this.yLocation + 57;
			 }else if(xLocation == 647 && yLocation < 635){
				this.yLocation = 647;
				this.xLocation = 605;
			 }
		
			
			}else if(startingpoint == 4){
			
					if(yLocation == 647 && xLocation > 122){  
						tokenLabel.setIcon(tokenIcon2);
				this.xLocation = this.xLocation - 57;
			 }else if(yLocation == 647 && xLocation > 57){
				this.xLocation = 23;
				this.yLocation = 635;
	
		              }else if(xLocation == 23 && yLocation > 122){  
							tokenLabel.setIcon(tokenIcon3);
				this.yLocation = this.yLocation -57 ;
			 }else if(xLocation == 23 && yLocation > 57){
				this.yLocation = 23;
			              this.xLocation = 35;
	
			 }else if(yLocation == 23 && xLocation < 548){  
					tokenLabel.setIcon(tokenIcon4);
				this.xLocation = this.xLocation + 57;
			 }else if(yLocation == 23 && xLocation < 605){
				this.xLocation = 647;
				this.yLocation = 35;
	
		             }else if(xLocation == 647 && yLocation < 548){  
							tokenLabel.setIcon(tokenIcon1);
		    	              this.yLocation = this.yLocation + 57;
			 }else if(xLocation == 647 && yLocation < 605){
				this.yLocation = 647;
				this.xLocation = 635;
			 }
		
			
			}else if(startingpoint == 5){
			
				if(yLocation == 669 && xLocation > 92){  
					tokenLabel.setIcon(tokenIcon2);
					this.xLocation = this.xLocation - 57;
				}else if(yLocation == 669 && xLocation > 35){
					this.xLocation = 1;
					this.yLocation = 605;
	
			    }else if(xLocation == 1 && yLocation > 92){  
					tokenLabel.setIcon(tokenIcon3);
					this.yLocation = this.yLocation -57 ;
				}else if(xLocation == 1 && yLocation > 35){
					this.yLocation = 1;
				              this.xLocation = 65;
	
				}else if(yLocation == 1 && xLocation < 578){  
					tokenLabel.setIcon(tokenIcon4);
					this.xLocation = this.xLocation + 57;
				}else if(yLocation == 1 && xLocation < 635){
					this.xLocation = 669;
					this.yLocation = 65;
	
			             }else if(xLocation == 669 && yLocation < 578){  
								tokenLabel.setIcon(tokenIcon1);
			    	              this.yLocation = this.yLocation + 57;
				}else if(xLocation == 669 && yLocation < 635){
					this.yLocation = 669;
					this.xLocation = 605 ;
				}
		
			
			}else if(startingpoint == 6){
			
				if(yLocation == 669 && xLocation > 122){  
					tokenLabel.setIcon(tokenIcon2);
					this.xLocation = this.xLocation - 57;
				}else if(yLocation == 669 && xLocation > 65){
					this.xLocation = 1;
					this.yLocation = 635;
	
			    }else if(xLocation == 1 && yLocation > 122){  
					tokenLabel.setIcon(tokenIcon3);
					this.yLocation = this.yLocation -57 ;
				}else if(xLocation == 1 && yLocation > 65){
					this.yLocation = 1;
				    this.xLocation = 35;
	
				}else if(yLocation == 1 && xLocation < 548){  
					tokenLabel.setIcon(tokenIcon4);
					this.xLocation = this.xLocation + 57;
				}else if(yLocation == 1 && xLocation < 605){
					this.xLocation = 669;
					this.yLocation = 35;
	
			    }else if(xLocation == 669 && yLocation < 548){  
					tokenLabel.setIcon(tokenIcon1);
			    	this.yLocation = this.yLocation + 57;
				}else if(xLocation == 669 && yLocation < 605){
					this.yLocation = 669;
					this.xLocation = 635;
				}
		
			
			}else if(startingpoint == 7){
			
					if(yLocation == 636 && xLocation > 107){  
						tokenLabel.setIcon(tokenIcon2);
				this.xLocation = this.xLocation - 57;
			 }else if(yLocation == 636 && xLocation > 50){
				this.xLocation = 34;
				this.yLocation = 620;
	
		              }else if(xLocation == 34 && yLocation > 107){  
							tokenLabel.setIcon(tokenIcon3);
				this.yLocation = this.yLocation -57;
			 }else if(xLocation == 34 && yLocation > 50){
				this.yLocation = 34;
			              this.xLocation = 54;
	
			 }else if(yLocation == 34 && xLocation < 567){  
					tokenLabel.setIcon(tokenIcon4);
				this.xLocation = this.xLocation + 57;
			 }else if(yLocation == 34 && xLocation < 624){
				this.xLocation = 636;
				this.yLocation = 54;
	
		             }else if(xLocation == 636 && yLocation < 567){  
							tokenLabel.setIcon(tokenIcon1);
		    	              this.yLocation = this.yLocation + 57;
			 }else if(xLocation == 636 && yLocation < 624){
				this.yLocation = 636;
				this.xLocation = 620;
			 }
		
			
			}else if(startingpoint == 8){
				if(yLocation == 658 && xLocation > 107){  
					tokenLabel.setIcon(tokenIcon2);
					this.xLocation = this.xLocation - 57;
				}else if(yLocation == 658 && xLocation > 50){
					this.xLocation = 12;
					this.yLocation = 620;
				}else if(xLocation == 12 && yLocation > 107){  
					tokenLabel.setIcon(tokenIcon3);
					this.yLocation = this.yLocation -57 ;
				}else if(xLocation == 12 && yLocation > 50){
					this.yLocation = 12;
			        this.xLocation = 54;
				}else if(yLocation == 12 && xLocation < 567){  
					tokenLabel.setIcon(tokenIcon4);
					this.xLocation = this.xLocation + 57;
				}else if(yLocation == 12 && xLocation < 624){
					this.xLocation = 658;
					this.yLocation = 54;
				}else if(xLocation == 658 && yLocation < 567){  
					tokenLabel.setIcon(tokenIcon1);
		    	    this.yLocation = this.yLocation + 57;
				}else if(xLocation == 658 && yLocation < 624){
					this.yLocation = 658;
					this.xLocation = 620 ;
			 }
		 }
      }
	
	public void unmoveToken(){

		if(startingpoint == 1)

						if(xLocation == 605 && yLocation == 625){
							this.yLocation =578;
							this.xLocation =625;
						}else if(xLocation == 625 && yLocation > 65){
							this.yLocation = this.yLocation - 57;     
						
						}else if(yLocation == 65 && xLocation == 625){
							this.xLocation =578;
							this.yLocation =45;
						}else if(yLocation == 45 && xLocation > 65){ 
						    this.xLocation = this.xLocation - 57;  

						}else if(xLocation == 65 && yLocation == 45){ 
							this.yLocation = 92;
							this.xLocation = 45;
						}else if(xLocation == 45 && yLocation < 605){ 
						    this.yLocation = this.yLocation +57 ;  

						}else if(yLocation == 605 && xLocation == 45){     
						    this.xLocation = 92;
						    this.yLocation = 625;
						}else if(yLocation == 625 && xLocation < 605){ 
							this.xLocation = this.xLocation + 57;   
						}		 
		if(startingpoint == 2)

						if(xLocation == 635 && yLocation == 625){
							this.yLocation =548;
							this.xLocation =625;
						}else if(xLocation == 625 && yLocation > 35){
							this.yLocation = this.yLocation - 57;     
						
						}else if(yLocation == 35 && xLocation == 625){
							this.xLocation =548;
							this.yLocation =45;
						}else if(yLocation == 45 && xLocation > 35){ 
						    this.xLocation = this.xLocation - 57;  
						
						}else if(xLocation == 35 && yLocation == 45){ 
							this.yLocation = 122;
							this.xLocation = 45;
						}else if(xLocation == 45 && yLocation < 635){ 
						    this.yLocation = this.yLocation +57 ;  
						
						}else if(yLocation == 635 && xLocation == 45){     
						    this.xLocation = 122;
						    this.yLocation = 625;
						}else if(yLocation == 625 && xLocation < 635){ 
							this.xLocation = this.xLocation + 57;   
						}



		if(startingpoint == 3)

						if(xLocation == 605 && yLocation == 647){
							this.yLocation =578;
							this.xLocation =647;
						}else if(xLocation == 647 && yLocation > 65){
							this.yLocation = this.yLocation - 57;     
						
						}else if(yLocation == 65 && xLocation == 647){
							this.xLocation =578;
							this.yLocation =23;
						}else if(yLocation == 23 && xLocation > 65){ 
						    this.xLocation = this.xLocation - 57;  

						}else if(xLocation == 65 && yLocation == 23){ 
							this.yLocation = 92;
							this.xLocation = 23;
						}else if(xLocation == 23 && yLocation < 605){ 
						    this.yLocation = this.yLocation +57 ;  

						}else if(yLocation == 605 && xLocation == 23){     
						    this.xLocation = 92;
						    this.yLocation = 647;
						}else if(yLocation == 647 && xLocation < 605){ 
							this.xLocation = this.xLocation + 57;   
						}



		if(startingpoint == 4)

						if(xLocation == 635 && yLocation == 647){
							this.yLocation =548;
							this.xLocation =647;
						}else if(xLocation == 647 && yLocation > 35){
							this.yLocation = this.yLocation - 57;     
						
						}else if(yLocation == 35 && xLocation == 647){
							this.xLocation =548;
							this.yLocation =23;
						}else if(yLocation == 23 && xLocation > 35){ 
						    this.xLocation = this.xLocation - 57;  
						
						}else if(xLocation == 35 && yLocation == 23){ 
							this.yLocation = 122;
							this.xLocation = 23;
						}else if(xLocation == 23 && yLocation < 635){ 
						    this.yLocation = this.yLocation +57 ;  
						
						}else if(yLocation == 635 && xLocation == 23){     
						    this.xLocation = 122;
						    this.yLocation = 647;
						}else if(yLocation == 647 && xLocation < 635){ 
							this.xLocation = this.xLocation + 57;   
						}


		if(startingpoint == 5)

						if(xLocation == 605 && yLocation == 669){
							this.yLocation =578;
							this.xLocation =669;
						}else if(xLocation == 669 && yLocation > 65){
							this.yLocation = this.yLocation - 57;     
						
						}else if(yLocation == 65 && xLocation == 669){
							this.xLocation =578;
							this.yLocation =1;
						}else if(yLocation == 1 && xLocation > 65){ 
						    this.xLocation = this.xLocation - 57;  
						
						}else if(xLocation == 65 && yLocation == 1){ 
							this.yLocation = 92;
							this.xLocation = 1;
						}else if(xLocation == 1 && yLocation < 605){ 
						    this.yLocation = this.yLocation +57 ;  
						
						}else if(yLocation == 605 && xLocation == 1){     
						    this.xLocation = 92;
						    this.yLocation = 669;
						}else if(yLocation == 669 && xLocation < 605){ 
							this.xLocation = this.xLocation + 57;   
						}

		if(startingpoint == 6){

						if(xLocation == 635 && yLocation == 669){
							this.yLocation =548;
							this.xLocation =669;
						}else if(xLocation == 669 && yLocation > 35){
							this.yLocation = this.yLocation - 57;     
						
						}else if(yLocation == 35 && xLocation == 669){
							this.xLocation =548;
							this.yLocation =1;
						}else if(yLocation == 1 && xLocation > 35){ 
						    this.xLocation = this.xLocation - 57;  
						
						}else if(xLocation == 35 && yLocation == 1){ 
							this.yLocation = 122;
							this.xLocation = 1;
						}else if(xLocation == 1 && yLocation < 635){ 
						    this.yLocation = this.yLocation +57 ;  
						
						}else if(yLocation == 635 && xLocation == 1){     
						    this.xLocation = 122;
						    this.yLocation = 669;
						}else if(yLocation == 669 && xLocation < 635){ 
							this.xLocation = this.xLocation + 57;   
						}
		}
		if(startingpoint == 7){

						if(xLocation == 620 && yLocation == 636){
							this.yLocation =567;
							this.xLocation =636;
						}else if(xLocation == 636 && yLocation > 65){
							this.yLocation = this.yLocation - 57;     
						
						}else if(yLocation == 54 && xLocation == 636){
							this.xLocation =567;
							this.yLocation =34;
						}else if(yLocation == 34 && xLocation > 65){ 
						    this.xLocation = this.xLocation - 57;  
						
						}else if(xLocation == 54 && yLocation == 34){ 
							this.yLocation = 107;
							this.xLocation = 34;
						}else if(xLocation == 34 && yLocation < 605){ 
						    this.yLocation = this.yLocation +57 ;  
						
						}else if(yLocation == 620 && xLocation == 34){     
						    this.xLocation = 107;
						    this.yLocation = 636;
						}else if(yLocation == 636 && xLocation < 605){ 
							this.xLocation = this.xLocation + 57;   
						}
		}
		if(startingpoint == 8){

						if(xLocation == 620 && yLocation == 658){
							this.yLocation =567;
							this.xLocation =658;
						}else if(xLocation == 658 && yLocation > 65){
							this.yLocation = this.yLocation - 57;     
						
						}else if(yLocation == 54 && xLocation == 658){
							this.xLocation =567;
							this.yLocation =12;
						}else if(yLocation == 12 && xLocation > 65){ 
						    this.xLocation = this.xLocation - 57;  
						
						}else if(xLocation == 54 && yLocation == 12){ 
							this.yLocation = 107;
							this.xLocation = 12;
						}else if(xLocation == 12 && yLocation < 605){ 
						    this.yLocation = this.yLocation +57 ;  
						
						}else if(yLocation == 620 && xLocation == 12){     
						    this.xLocation = 107;
						    this.yLocation = 658;
						}else if(yLocation == 658 && xLocation < 605){ 
							this.xLocation = this.xLocation + 57;   
						}
		}

	}
	
	/*
	public void moveToken(){
		if(yLocation == 615 && xLocation > 55){
			this.xLocation = this.xLocation - 56;
		}else if(xLocation == 55 && yLocation > 55){
			this.yLocation = this.yLocation - 56;
		}else if(yLocation == 55 && xLocation < 615){
			this.xLocation = this.xLocation + 56;
		}else if(xLocation == 615 && yLocation < 615){
			this.yLocation = this.yLocation + 56;
		}
	}
	*/
	public void createLabel(){
		this.tokenLabel = new JLabel(tokenIcon1);
	}
	
	public void moveLocation(int dice){
		this.setLocation((tokenLocation + dice)%40);
	}
	
	public void gotoLocation(int Location){
		this.setLocation(Location);
	}
	
	public void setxLocation(int xLocation) {
		this.xLocation = xLocation;
	}
	
	public int getxLocation() {
		return xLocation;
	}
	
	public void setyLocation(int yLocation) {
		this.yLocation = yLocation;
	}
	
	public int getyLocation() {
		return yLocation;
	}
	
	public void setAvailabe(boolean isAvailabe) {
		this.isAvailable = isAvailabe;
	}
	
	public boolean isAvailabe() {
		return isAvailable;
	}
	
	public void setTokenName(String tokenName) {
		this.tokenName = tokenName;
	}
	
	public String getTokenName() {
		return tokenName;
	}

	public void setLocation(int location) {
		tokenLocation = location;
	}

	public int getLocation() {
		return tokenLocation;
	}

	public void setGoToJail(boolean isGoToJail) {
		this.isGoToJail = isGoToJail;
	}
	
	public boolean isGoToJail() {
		return isGoToJail;
	}
	
	public void setTokenLabel(JLabel tokenLabel) {
		this.tokenLabel = tokenLabel;
	}
	
	public JLabel getTokenLabel() {
		return tokenLabel;
	}

	public void setTokenIcon(ImageIcon tokenIcon) {
		this.tokenIcon1 = tokenIcon;
	}

	public ImageIcon getTokenIcon() {
		return tokenIcon1;
	}

	public void setTokenIcon2(ImageIcon tokenIcon2) {
		this.tokenIcon2 = tokenIcon2;
	}

	public ImageIcon getTokenIcon2() {
		return tokenIcon2;
	}

	public void setTokenIcon3(ImageIcon tokenIcon3) {
		this.tokenIcon3 = tokenIcon3;
	}

	public ImageIcon getTokenIcon3() {
		return tokenIcon3;
	}

	public void setTokenIcon4(ImageIcon tokenIcon4) {
		this.tokenIcon4 = tokenIcon4;
	}

	public ImageIcon getTokenIcon4() {
		return tokenIcon4;
	}
}
